'https://www.youzy.cn/tzy/search/colleges/collegeList'
import json
import execjs
import requests

js_compile = execjs.compile(open('yzy.js', 'r', encoding='utf-8').read())


headers = {
    'Accept': '*/*',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Cache-Control': 'no-cache',
    'Connection': 'keep-alive',
    'Content-Type': 'application/json',
    'Origin': 'https://pv4y-pc.youzy.cn',
    'Pragma': 'no-cache',
    'Referer': 'https://pv4y-pc.youzy.cn/',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'same-site',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
    'sec-ch-ua': '"Not)A;Brand";v="99", "Google Chrome";v="127", "Chromium";v="127"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    # 'u-sign': '643ff9499febb3ee34c95ffe0bb29cb0',
    'u-token': '',
}

json_data = {
    'keyword': '',
    'provinceNames': [],
    'natureTypes': [],
    'eduLevel': '',
    'categories': [],
    'features': [],
    'pageIndex': 1,
    'pageSize': 20,
    'sort': 11,
}
json_str = json.dumps(json_data, separators=(',', ':'))
sign = js_compile.call('get_sign', '/youzy.dms.basiclib.api.college.query', json_data)
headers['u-sign'] = sign
response = requests.post(
    'https://uwf7de983aad7a717eb.youzy.cn/youzy.dms.basiclib.api.college.query',
    headers=headers,
    data=json_str,
)
print(response.text)
